<?php
/**
 * LICENSE
 *
 * Copyright (C) 2010 Nicholas Miller
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or any
 * later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Uses a Zend Log Writer to record details regarding SOAP activity with PayPal
 *
 * @author     Nicholas Miller <nicholas.j.miller@gmail.com>
 * @copyright  2010 Nicholas Miller
 * @category   PaypalSoap
 * @package    Observer
 */
class PayPalSoap_Client_Observer_Logger extends PayPalSoap_Client_Observer_Abstract
{
    /**
     * Logger
     * @var Zend_Log_Writer_Abstract
     */
    protected $_logger;

    /**
     * Class Constructor
     * 
     * @param Zend_Log_Writer_Abstract $logger Logging mechanism
     */
    public function __construct(Zend_Log_Writer_Abstract $logger)
    {
        $this->setLogger($logger);
    }

    /**
     * Gets registered logger
     * @return Zend_Log_Writer_Abstract
     */
    public function getLogger()
    {
        return $this->_logger;
    }

    /**
     * Sets registered logger
     * @return void
     */
    public function setLogger(Zend_Log_Writer_Abstract $logger)
    {
        $this->_logger = $logger;
    }

    /**
     * Observer update
     * @param SplSubject $subject
     */
    public function update(SplSubject $subject)
    {
        /* @var $subject PayPalSoap_Client */
        $this->_logger->write($subject->getLastRequest() . "\n" . $subject->getLastResponse());
    }
}